package com.yc.ycpaimon.viewmodel

import androidx.lifecycle.asLiveData
import com.yc.jetpacklib.extension.ycFlowSync
import com.yc.ycpaimon.base.BaseViewModel
import com.yc.ycpaimon.repository.VersionRepo
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.zip

/**
 * Creator: yc
 * Date: 2022/2/17 18:31
 * UseDes:
 */
class WelcomeVM : BaseViewModel() {
    private val mVersionRepo by lazy { VersionRepo(mApiGithub) }

    fun versionUpdate() = mVersionRepo.versionUpdate().ycHasLoading().asLiveData()

    fun test() {
        ycFlowSync {
            val json = mVersionRepo.versionUpdate2()
            val json2 = mVersionRepo.versionUpdate3()
        }
        val flow1 = mVersionRepo.versionUpdate()
        val flow2 = mVersionRepo.versionUpdate22()
        val flow3 = mVersionRepo.versionUpdate33()
        ycLaunch {
            flow1.zip(flow2) { data1, dat2 ->
                val data1_2 = dat2
                data1_2
            }.zip(flow3) { data1_2, dat3 ->

            }.collect()
        }
    }
}